package com.sikaryofficial.backend.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sikaryofficial.backend.config.TenantFilterProperties;
import com.sikaryofficial.backend.domain.dto.resp.StoreListDTO;
import com.sikaryofficial.backend.domain.entity.StoreEvaluate;
import com.sikaryofficial.backend.mapper.StoreEvaluateMapper;
import com.sikaryofficial.backend.service.IStoreEvaluateService;
import com.sikaryofficial.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 店铺分享记录Service业务层处理
 *
 * @author qinjinyuan
 * @date 2023-10-27
 */
@Service
public class StoreEvaluateServiceImpl extends ServiceImpl<StoreEvaluateMapper, StoreEvaluate> implements IStoreEvaluateService {
    @Autowired
    private StoreEvaluateMapper storeEvaluateMapper;

    @Autowired
    private TenantFilterProperties tenantFilterProperties;
    /**
     * 最新被评价的店铺
     * 店铺被评价，需要更新店铺的更新时间
     *
     * @param sourceCode
     * @return
     */
    @Override
    public IPage<StoreListDTO> storeListBySource(Page<StoreListDTO> customerPage, String sourceCode) {
        String brandNo = SecurityUtils.getBrand();
        Integer tenantId = tenantFilterProperties.getTenantByBrand(brandNo);
        return storeEvaluateMapper.storeListBySource(customerPage,sourceCode, SecurityUtils.getUserId(),tenantId);
    }
}

